using System;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace ns20
{
	internal class Class169 : Class167
	{
		[CompilerGenerated]
		private sealed class Class171<T>
		{
			public Type type_0;

			public T method_0()
			{
				return (T)Activator.CreateInstance(type_0);
			}

			public T method_1()
			{
				return (T)Activator.CreateInstance(type_0);
			}
		}

		private static readonly Class169 class169_0 = new Class169();

		internal static Class167 Class167_0 => class169_0;

		public override Delegate3<T, object> ns20_002EClass167_002E_206A_206E_200E_202E_206E_200B_200B_200E_202C_206A_202A_202B_200C_206A_206C_206D_202B_200F_206E_200F_202C_200D_200D_202B_202B_206F_206D_206E_206D_206B_200B_206B_200B_200E_200D_202E_202A_206C_200F_202B_202E<T>(MethodBase methodBase_0)
		{
			Class204.smethod_2(methodBase_0, "method");
			Type typeFromHandle = typeof(object);
			ParameterExpression parameterExpression = Expression.Parameter(typeFromHandle, "target");
			ParameterExpression parameterExpression2 = Expression.Parameter(typeof(object[]), "args");
			ParameterInfo[] parameters = methodBase_0.GetParameters();
			Expression[] array = new Expression[parameters.Length];
			for (int i = 0; i < parameters.Length; i++)
			{
				Expression index = Expression.Constant(i);
				Expression expression_ = Expression.ArrayIndex(parameterExpression2, index);
				expression_ = (array[i] = method_2(expression_, parameters[i].ParameterType));
			}
			Expression expression;
			if (methodBase_0.IsConstructor)
			{
				expression = Expression.New((ConstructorInfo)methodBase_0, array);
			}
			else if (methodBase_0.IsStatic)
			{
				expression = Expression.Call((MethodInfo)methodBase_0, array);
			}
			else
			{
				Expression instance = method_2(parameterExpression, methodBase_0.DeclaringType);
				expression = Expression.Call(instance, (MethodInfo)methodBase_0, array);
			}
			if (methodBase_0 is MethodInfo)
			{
				MethodInfo methodInfo = (MethodInfo)methodBase_0;
				expression = ((!(methodInfo.ReturnType != typeof(void))) ? Expression.Block(expression, Expression.Constant(null)) : method_2(expression, typeFromHandle));
			}
			LambdaExpression lambdaExpression = Expression.Lambda(typeof(Delegate3<T, object>), expression, parameterExpression, parameterExpression2);
			return (Delegate3<T, object>)lambdaExpression.Compile();
		}

		public override Func<T> ns20_002EClass167_002E_206E_206D_200F_202C_202B_206A_206E_200E_202B_206A_206F_206A_202E_202C_206E_202D_202A_202D_202B_206F_206C_202D_206C_206C_202A_206E_200B_206A_202A_202C_206B_200C_206A_206A_200B_206D_206A_206E_200E_206E_202E<T>(Type type_0)
		{
			Class204.smethod_2(type_0, "type");
			if (type_0.smethod_10())
			{
				return () => (T)Activator.CreateInstance(type_0);
			}
			try
			{
				Type typeFromHandle = typeof(T);
				Expression expression_ = Expression.New(type_0);
				expression_ = method_2(expression_, typeFromHandle);
				LambdaExpression lambdaExpression = Expression.Lambda(typeof(Func<T>), expression_);
				return (Func<T>)lambdaExpression.Compile();
			}
			catch
			{
				return () => (T)Activator.CreateInstance(type_0);
			}
		}

		public override Func<T, object> ns20_002EClass167_002E_200B_200C_202E_200C_202A_206E_206E_202B_202E_206F_200F_200E_202C_200C_206D_206C_200C_206E_202D_206E_200C_202D_200E_206D_200D_206C_200F_202C_200F_206C_200B_202B_202E_200B_202D_206B_202E_206A_200D_200C_202E<T>(PropertyInfo propertyInfo_0)
		{
			Class204.smethod_2(propertyInfo_0, "propertyInfo");
			Type typeFromHandle = typeof(T);
			Type typeFromHandle2 = typeof(object);
			ParameterExpression parameterExpression = Expression.Parameter(typeFromHandle, "instance");
			MethodInfo getMethod = propertyInfo_0.GetGetMethod(nonPublic: true);
			Expression expression_;
			if (getMethod.IsStatic)
			{
				expression_ = Expression.MakeMemberAccess(null, propertyInfo_0);
			}
			else
			{
				Expression expression = method_2(parameterExpression, propertyInfo_0.DeclaringType);
				expression_ = Expression.MakeMemberAccess(expression, propertyInfo_0);
			}
			expression_ = method_2(expression_, typeFromHandle2);
			LambdaExpression lambdaExpression = Expression.Lambda(typeof(Func<T, object>), expression_, parameterExpression);
			return (Func<T, object>)lambdaExpression.Compile();
		}

		public override Func<T, object> ns20_002EClass167_002E_200B_200C_202E_200C_202A_206E_206E_202B_202E_206F_200F_200E_202C_200C_206D_206C_200C_206E_202D_206E_200C_202D_200E_206D_200D_206C_200F_202C_200F_206C_200B_202B_202E_200B_202D_206B_202E_206A_200D_200C_202E<T>(FieldInfo fieldInfo_0)
		{
			Class204.smethod_2(fieldInfo_0, "fieldInfo");
			ParameterExpression parameterExpression = Expression.Parameter(typeof(T), "source");
			Expression expression_;
			if (fieldInfo_0.IsStatic)
			{
				expression_ = Expression.Field(null, fieldInfo_0);
			}
			else
			{
				Expression expression = method_2(parameterExpression, fieldInfo_0.DeclaringType);
				expression_ = Expression.Field(expression, fieldInfo_0);
			}
			expression_ = method_2(expression_, typeof(object));
			return Expression.Lambda<Func<T, object>>(expression_, new ParameterExpression[1] { parameterExpression }).Compile();
		}

		public override Action<T, object> ns20_002EClass167_002E_206B_202C_206B_200B_202C_202E_200C_202C_200E_206B_206D_200B_202D_206A_200F_202D_206B_206D_200E_202C_206F_200D_206D_206B_206B_200D_200C_202E_206D_202A_200D_206B_202E_200F_200F_202D_206C_200C_200D_206E_202E<T>(FieldInfo fieldInfo_0)
		{
			Class204.smethod_2(fieldInfo_0, "fieldInfo");
			if (!fieldInfo_0.DeclaringType.smethod_12() && !fieldInfo_0.IsInitOnly)
			{
				ParameterExpression parameterExpression = Expression.Parameter(typeof(T), "source");
				ParameterExpression parameterExpression2 = Expression.Parameter(typeof(object), "value");
				Expression expression;
				if (fieldInfo_0.IsStatic)
				{
					expression = Expression.Field(null, fieldInfo_0);
				}
				else
				{
					Expression expression2 = method_2(parameterExpression, fieldInfo_0.DeclaringType);
					expression = Expression.Field(expression2, fieldInfo_0);
				}
				Expression right = method_2(parameterExpression2, expression.Type);
				BinaryExpression body = Expression.Assign(expression, right);
				LambdaExpression lambdaExpression = Expression.Lambda(typeof(Action<T, object>), body, parameterExpression, parameterExpression2);
				return (Action<T, object>)lambdaExpression.Compile();
			}
			return Class170.Class167_0.ns20_002EClass167_002E_206B_202C_206B_200B_202C_202E_200C_202C_200E_206B_206D_200B_202D_206A_200F_202D_206B_206D_200E_202C_206F_200D_206D_206B_206B_200D_200C_202E_206D_202A_200D_206B_202E_200F_200F_202D_206C_200C_200D_206E_202E<T>(fieldInfo_0);
		}

		public override Action<T, object> ns20_002EClass167_002E_206B_202C_206B_200B_202C_202E_200C_202C_200E_206B_206D_200B_202D_206A_200F_202D_206B_206D_200E_202C_206F_200D_206D_206B_206B_200D_200C_202E_206D_202A_200D_206B_202E_200F_200F_202D_206C_200C_200D_206E_202E<T>(PropertyInfo propertyInfo_0)
		{
			Class204.smethod_2(propertyInfo_0, "propertyInfo");
			if (propertyInfo_0.DeclaringType.smethod_12())
			{
				return Class170.Class167_0.ns20_002EClass167_002E_206B_202C_206B_200B_202C_202E_200C_202C_200E_206B_206D_200B_202D_206A_200F_202D_206B_206D_200E_202C_206F_200D_206D_206B_206B_200D_200C_202E_206D_202A_200D_206B_202E_200F_200F_202D_206C_200C_200D_206E_202E<T>(propertyInfo_0);
			}
			Type typeFromHandle = typeof(T);
			Type typeFromHandle2 = typeof(object);
			ParameterExpression parameterExpression = Expression.Parameter(typeFromHandle, "instance");
			ParameterExpression parameterExpression2 = Expression.Parameter(typeFromHandle2, "value");
			Expression expression = method_2(parameterExpression2, propertyInfo_0.PropertyType);
			MethodInfo setMethod = propertyInfo_0.GetSetMethod(nonPublic: true);
			Expression body;
			if (setMethod.IsStatic)
			{
				body = Expression.Call(setMethod, expression);
			}
			else
			{
				Expression instance = method_2(parameterExpression, propertyInfo_0.DeclaringType);
				body = Expression.Call(instance, setMethod, expression);
			}
			LambdaExpression lambdaExpression = Expression.Lambda(typeof(Action<T, object>), body, parameterExpression, parameterExpression2);
			return (Action<T, object>)lambdaExpression.Compile();
		}

		private Expression method_2(Expression expression_0, Type type_0)
		{
			Type type = expression_0.Type;
			if (!(type == type_0) && (type.smethod_12() || !type_0.IsAssignableFrom(type)))
			{
				return Expression.Convert(expression_0, type_0);
			}
			return expression_0;
		}
	}
}
